package com.yenlien.traceyun.control.dao;

import com.yenlien.traceyun.control.entity.Crop;
import com.yenlien.traceyun.webase.dao.BaseJpaDao;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by LiuSha on 2020/3/24.
 */
public interface CropDao extends BaseJpaDao<Crop> {
    Crop findById(String id);

    @Query(value = "select * from t_crop where model_id = ?1 ORDER BY sort ", nativeQuery = true)
    List<Crop> findByModelId(String modelId);

    /**
     * 根据ids删除
     *
     * @param modelIds
     */
    @Transactional(rollbackFor = RuntimeException.class, propagation = Propagation.REQUIRED)
    public void deleteByModelIdIn(List<String> modelIds);

    public void deleteByModelId(String modelId);
}
